<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<!-- 引入easyui 的主题样式  和  easyui 提供的图标样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<!-- 引入jquery 和  easyui.js   中文设置js-->
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
	$(function(){
		$('#dg').datagrid({    
		    url:'resign',    
		    columns:[[
		        {field:'ck',checkbox:true},
				{field:'eid',title:'员工id',width:100}, 
		        {field:'ename',title:'姓名',width:100},
		        {field:'dname',title:'部门',width:100}, 
		        {field:'eposition',title:'职位',width:100}, 
		        {field:'ltime',title:'申请时间',width:100}, 
		        {field:'reason',title:'离职原因',width:100}, 
		        {field:'date',title:'离职时间',width:100},
		        {field:'state',title:'审核状态',width:100},
		        {field:'opertion',title:'操作',width:100,
		        	formatter: function(value,row,index){
						var val="<a href='#' onclick='showDetail("+row.id+")'>查看</a>";
						return val;
					}
	      	
		      	}    
		    ]],
		    //分页工具栏
		    pagination:true,
		    //singleSelect:true,
		    toolbar: [{
		    	text:'待审核',
				iconCls: 'icon-edit',
				handler: function(){
					$('#dg').datagrid('load', {    
					    state: '待审核',    
					});
				}
			},'--',{
				text:'已审核',
				iconCls: 'icon-edit',
				handler: function(){
					$('#dg').datagrid('load', {    
					    state: '已审核',    
					});
				}
			},'--',{
				text:'统计',
				iconCls: 'icon-edit',
				handler: function(){
					$('#dg').datagrid('load', {    
					    state: '',    
					});
				}
			},'--',{
				text:'删除记录',
				iconCls: 'icon-remove',
				handler: function(){
					var dels=[];
					var sels=$('#dg').datagrid('getSelections');
					if(sels!=0){
						$.messager.confirm('确认','您确认想要删除记录吗？',function(r){    
						    if (r){    
						    	$.each(sels,function(i,n){
									dels.push(n.id);
								})
								$.ajax({
								url:'delResign',
								type:'post',
								data:{"ids":dels},
								traditional: true,
								dataType:'text',
								success:function(data){
									if(data=='true'){
			    						$.messager.alert('提示','删除成功');
			    						$('#dg').datagrid('reload');
			    					}else{
			    						$.messager.alert('提示','删除失败');
			    					}
								}		
								})
							}    
					  });	
					}else{
						$.messager.alert('提示','请选择记录删除');
					}
				}
			}]
		}); 
		//查看申请单窗口
		$('#win').window({
			title:' ',
		    width:600,    
		    height:400,    
		    modal:true,
		    closed:true,
		    collapsible:false
		});
	})
	//点击查看按钮（lzsh）
		function showDetail(id){
			$('#win').window('open');
			var id=id;
			$.ajax({
				url:'resigndata',
				type:'post',
				data:{'id':id},
				dataType:'json',
				success:function(data){
					var da=data;
					$('#ename').textbox('setText',da.re.ename);
					$('#date').textbox('setText',da.re.date);
					$('#dname').textbox('setText',da.re.dname);
					$('#eid').textbox('setText',da.re.eid);
					$('#reason').textbox('setText',da.re.reason);
					$('#ltime').textbox('setText',da.re.ltime);
					$('#opinion').combobox('setValue',da.re.opinion);
					$('#retime').textbox('setText',da.re.retime);
					$('#state').textbox('setText',da.re.state);
					$('#remark').val(da.re.remark);//textarea
				}
			})
			//配置提交按钮
		$('#save').bind('click',function(){
			//配置离职审核form表单
			$('#ff').form('submit', {    
			    url:'checkResign',    
			    onSubmit: function(param){
			        param.id = id;     
			    },  
			    success:function(data){    
			        if(data=='true'){
			        	$.messager.alert('提示','提交成功');
			        	$('#ff').form('clear');
			        	$('#win').window('close');
			        }else{
			        	$.messager.alert('提示','提交失败');
			        }	        
			        $('#dg').datagrid('reload'); 
			    }    
			}); 
		})
		$('#cancle').bind('click', function(){    
		     $('#ff').form('clear');
			$('#win').window('close');
		});		
	}
	$(function(){
		//yglz搜索框
		$('#ss').searchbox({ 
			searcher:function(value,name){ 
				if(name=='姓名'){
					$('#dg').datagrid('load', {    
					    ename: value,
					});   
				}else{
					$('#dg').datagrid('load',{
						eid:value,
					})
				}	
			}, 
				menu:'#mm', 
				prompt:'请输入......' 
			});
	})

</script>
<body>
<!-- lzsh上面搜索框 -->
	<input id="ss" style="width: 300px"></input> 
		<div id="mm" > 
		<div data-options="ename:'ename'">姓名</div> 
		<div data-options="eid:'eid'">员工id</div> 
	</div>
<!-- 离职申请页面 -->
	<table id="dg"></table>
	<!-- 离职申请表单 -->
	<div id="win">
	<form id="ff" method="post"> 
		<h2 align="center">离职申请单</h2>
			<div style='margin-left: 33px;margin-top: 10px'>		
			申请人:<input id='ename'  class="easyui-textbox" type="text" data-options="readonly:true"/>
			&nbsp
			申请日期:<input id='date'  class="easyui-textbox" type="text" data-options="readonly:true"/>			
		</div>
		<div style='margin-left: 45px;margin-top: 5px'>
			部门:<input id='dname'  class="easyui-textbox" type="text" data-options="readonly:true"/>
			&nbsp&nbsp&nbsp&nbsp&nbsp
			员工id:<input id='eid'  class="easyui-textbox" type="text" data-options="readonly:true"/>
		</div>
		<div style='margin-left: 25px;margin-top: 5px'>
			离职原因:<input id='reason'  class="easyui-textbox" type="text" data-options="readonly:true"/>
		</div>
		<div style='margin-left: 25px;margin-top: 5px'>
			离职时间:<input id='ltime' class="easyui-textbox" type="text" data-options="readonly:true"/>
		</div>
		<div style='margin-left: 25px;margin-top: 5px;color: red;'>
			审批状态:<input id='state' class="easyui-textbox" type="text" data-options="readonly:true"/>
		</div>
		<br>
		<hr/>
		<div style='margin-left: 25px;margin-top: 5px'>
			审核意见:<select id="opinion" name="opinion" class="easyui-combobox" style="width:150px;" data-options="editable:false,panelHeight:'auto'" >   
			    <option>同意</option>   
			    <option>不同意</option>      
			</select>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
			审核时间:<input id="retime" name='retime' type="text" class="easyui-datebox" data-options="required:true,validType:'date'"></input>  
		</div>
		<div style='margin-left: 28px'>
			备注:<br>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
			<textarea id='remark' name='remark' rows="4" cols="55" data-options="readonly:true"></textarea>
		</div>
		<br>
		<div style='margin-left: 200px'>
			<a id="save" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">提交</a>
			&nbsp&nbsp&nbsp&nbsp&nbsp 
			<a id="cancle" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">取消</a> 
		</div>
	</form> 
	</div>
</body>
</html>